

// pages/creatreume/creatreume.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    items:["姓名","年级","学院","专业","技能","经历(奖项)","兴趣","个人介绍"],
    file:"",
    value:["","","","","","","","","","","",""]
  },
  getimage(){
    var that=this
    wx.chooseMedia({
      count: 1,
      sizeType: ['original', 'compressed'],//图片尺寸：original:原图，compressed：压缩图
      sourceType: ['album', 'camera'],//图片来源：album：从相册选图，camera:使用相机
      mediaType: ['image'],
      camera:'back',
      success:(res)=> {
      that.setData({
        file:res.tempFiles[0].tempFilePath
      })
      }
      })
  },
  getitem(e){
   var index=e.currentTarget.dataset.index
   var value=this.data.value;
   value[index]=e.detail
   this.setData({
     value:value
   })
  },
  sumbit(e){
    if(!this.data.file){
      Notify({
        message: '请上传头像',
        color: '#FFF',
        background: '#C5CEFD',
      });      
    }else{
      if(!(this.data.value[0]&&this.data.value[1]&&this.data.value[2]&&this.data.value[3]&&this.data.value[4]&&this.data.value[5]&&this.data.value[6]&&this.data.value[7])){
        Notify({
          message: '请填写完整',
          color: '#FFF',
          background: '#C5CEFD',
        });   
      }else{
        var token=getApp().globalData.accessToken
        var formData={
          interest:this.data.value[6],
          introduction:this.data.value[7],
          online:1,
          name:this.data.value[0],
          grade:this.data.value[1],
          college:this.data.value[2],
          og:this.data.value[3],
          skill:this.data.value[4],
          experience:this.data.value[5]
        }
        axios.uploadfile("/user/resume",formDatam,this.data.file,"file")
        wx.navigateBack({
          delta:1
        })
      }
    }
    

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    var that=this
    wx.getSetting({
      success(res) {
        if (!res.authSetting['scope.userInfo']) {
          wx.authorize({
            scope: 'scope.userInfo',
            success () {
              wx.getUserInfo({
               success:res=>{
                var file=res.userInfo.avatarUrl
                wx.getImageInfo({
                  src:file,
                  success:res=>{
                    that.setData({
                      file:res.path
                    })
                  }
                })
               }
              })
            },
          })
        }else{
          wx.getUserInfo({
            success:res=>{
            var  file=res.userInfo.avatarUrl
            wx.getImageInfo({
              src:file,
              success:res=>{
                that.setData({
                  file:res.path
                })
              }
            })
            }
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})